using System;
using UnityEngine;
using Voodoo.Pattern;

public class OnboardingManager : SingletonMB<OnboardingManager>
{
	public struct IncrementalButtonStates
	{
		public bool LongVisible;

		public bool LongIsFree;

		public bool OilVisible;

		public bool OilIsFree;

		public bool PowerVisible;

		public bool PowerIsFree;

		public bool SizeVisible;

		public bool SizeIsFree;
	}

	public int LongStartAtGame = 1;

	public int OilStartAtGame = 2;

	public int PowerStartAtGame = 3;

	public int SizeStartAtGame = 3;

	private int GetNumberGamePlayed
	{
		get
		{
			return NintendoPlayerPrefs.GetInt("onboarding_game_count", 0);
		}
		set
		{
			NintendoPlayerPrefs.SetInt("onboarding_game_count", value);
		}
	}

	public int AllIncrementalAccessibleAtGame => 1 + Mathf.Max(LongStartAtGame, OilStartAtGame, PowerStartAtGame, SizeStartAtGame);

	public bool IsOnboardingActive
	{
		get
		{
			if (Preloader.OnboardingConfig.IsEnabled)
			{
				return GetNumberGamePlayed < AllIncrementalAccessibleAtGame;
			}
			return false;
		}
	}

	private void Start()
	{
		GameManager instance = SingletonMB<GameManager>.Instance;
		instance.OnGameStart = (Action)Delegate.Combine(instance.OnGameStart, (Action)delegate
		{
			GetNumberGamePlayed++;
		});
	}

	public IncrementalButtonStates GetIncrementalStates()
	{
		IncrementalButtonStates result = default(IncrementalButtonStates);
		result.LongVisible = GetNumberGamePlayed >= AllIncrementalAccessibleAtGame || GetNumberGamePlayed == LongStartAtGame;
		result.LongIsFree = GetNumberGamePlayed == LongStartAtGame;
		result.OilVisible = GetNumberGamePlayed >= AllIncrementalAccessibleAtGame || GetNumberGamePlayed == OilStartAtGame;
		result.OilIsFree = GetNumberGamePlayed == OilStartAtGame;
		result.PowerVisible = GetNumberGamePlayed >= AllIncrementalAccessibleAtGame || GetNumberGamePlayed == PowerStartAtGame;
		result.PowerIsFree = GetNumberGamePlayed == PowerStartAtGame;
		result.SizeVisible = GetNumberGamePlayed >= AllIncrementalAccessibleAtGame || GetNumberGamePlayed == SizeStartAtGame;
		result.SizeIsFree = GetNumberGamePlayed == SizeStartAtGame;
		return result;
	}
}
